package CompleteFutureDemo;

import common.CalcTask;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @author chao
 * @create 2022-02-06-17:12
 */
public class ThenComposeTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Double> cf = CompletableFuture.supplyAsync(() -> null);
        CompletableFuture<String> cf2 = cf.thenCompose((result) -> {
            new CalcTask().Run();
            return CompletableFuture.supplyAsync(() -> {
                System.out.println("执行 job3");
                return "job3 result";
            });
        });
        System.out.println("cf 结果 -> " + cf.get() );
        System.out.println("cf2 结果 -> "+cf2.get());
    }
}
